const { Sequelize, DataTypes } = require("sequelize");
const sequelize = require('.')
// 展厅
const ShowRoom = sequelize.define(
  "ShowRoom",
  {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    name: {
      type: DataTypes.STRING,
      defaultValue: null,
    },
    status: {
      type: DataTypes.INTEGER,
      defaultValue: 1, // 开馆：1，闭馆：2
    }
  },
  {
    timestamps: false,
  }
);

// const createTable = (sequelize) => {

//   return sequelize;
// };
async function deleteAll() {
  await ShowRoom.destroy({
    where: {},
    truncate: true,
  });
}
async function create(params) {
  const showrooms = [
      { id: 3, name: "储能集成工厂"},
      { id: 4, name: "储能PACK车间"},
      { id: 7, name: "梦想与创新展示中心"},
      { id: 5, name: "储能电芯实验室"},
      { id: 2, name: "支架展厅&车间"},
      { id: 1, name: "光伏展厅&车间"},
      { id: 6, name: "国家级光伏研究院展示中心"},
      { id: 8, name: "光伏生产M3车间"},
    ]
  for (let i of showrooms) {
    ShowRoom.create({
      id: i.id,
      name: i.name,
    });
  }
}
(async () => {
  await ShowRoom.sync({alter: false}); // Creates the table if it doesn't exist
  // await deleteAll();
  // await create()
})();

module.exports = ShowRoom